package ro.flashbite.loaders.types
{
	import ro.flashbite.sound.SoundChannelIds;
	
	import flash.events.Event;
	import flash.media.Sound;
	
	/**
	 *
	 * This will load a sound file
	 *  
	 * @author Adrian Barbu
	 * 
	 */	
	public final class SoundAsset extends Asset
	{
		/**
		 * string for logger 
		 */		
		private static const NAME	:	String 	= "SoundAsset";
		
		private var _channelID	:	String;
		
		//=================================================================================================
		// CONSTRUCTOR
		//=================================================================================================
		
		public function SoundAsset(channelID:String = SoundChannelIds.VOICE)
		{
			super();
			
			_channelID = channelID;
		}
		
		//==================================================================================================
		// PROTECTED OVERRIDES
		//==================================================================================================
		
		override protected function setLoggerName():void
		{
			_loggerName = NAME;
		}
		
		override protected function setLoaderAndDispacher():void
		{
			_loader = new Sound();
			_loaderDispacher = _loader;
		}
		
		override protected function onComplete(e:Event):void
		{
			if (_loaderDispacher && _loader) {
				_content = _loader;
					
				removeListenersFromLoader(_loaderDispacher);
			}	
			
			super.onComplete(e);
		}
		
		//==================================================================================================
		// DESTRUCTOR
		//==================================================================================================
		
		override public function destroy():void
		{
			super.destroy();
			
			_channelID = null;
		}
		
		//==================================================================================================
		// GETTERS
		//==================================================================================================
		
		public function get channelID():String { return _channelID; }
	}
}